<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('学生做实验页面')"/>
    <th:block th:include="include :: summernote-css"/>
</head>
<body class="gray-bg">
<div class="container" style="text-align: center">
    <br><br>
    <h2 th:text="${onlineExperimentStu.onlineExperimentTea.experimentTeaName}"></h2>
    <br>
    <div style="padding-bottom: 30px">
        <h3>实验时间</h3>
        <span th:text="${#dates.format(onlineExperimentStu.onlineExperimentTea.experimentTeaBeginTime,'yyyy-MM-dd')}+'--'+${#dates.format(onlineExperimentStu.onlineExperimentTea.experimentTeaEndTime,'yyyy-MM-dd')}"></span>
    </div>
    <h3>在线实验结果</h3>
    <input th:value="${onlineExperimentStu.u3dScore}" type="text" id="u3dMessage" hidden="hidden"/>
    <div class="row" >
        <div class="col-md-3"></div>
        <div class="col-md-6" id="u3dScore" style="border: 1px solid gainsboro;  box-shadow: 0px 0px 4px gainsboro; border-radius:20px ;background-color: white;">
            <table class="table" id="dataTable">

            </table>
        </div>
        <div class="col-md-3"></div>
    </div>
</div>
<br>
<div class="container">
    <h3 style="text-align: center">实验报告</h3>
    <input th:value="${onlineExperimentStu.experimentReport}" type="text" id="report" hidden="hidden"/>
    <div class="summernote">

    </div>
    <br>
    <h3 style="text-align: center">请输入教师评语</h3>
    <div>
        <div class="summernote1">

        </div>
    </div>
    <div class="row">
        <div class="col-md-5">
            <div class="col-md-6"><span>请输入分數</span></div>
            <div class="col-md-6">
                <input type="text" class="form-control" id="score"/>
            </div>
        </div>
        <div class="col-md-4">
            <button type="button" class="btn btn-warning form-control" onclick="checkHomework()">确定</button>
        </div>
        <div class="col-md-3">

        </div>
    </div>
</div>
<input type="text" th:value="${onlineExperimentStu.studentId}" id="studentId" hidden="hidden"/>
<input type="text" th:value="${onlineExperimentStu.experimentTeaId}" id="experimentTeaId" hidden="hidden">
<th:block th:include="include :: footer"/>
<th:block th:include="include :: summernote-js"/>
</body>
<script>
    $(function () {
        var u3dScore = $("#u3dMessage").val();
        var array = new Array();
        array = u3dScore.split("/");
        for (var i = 0; i < array.length; i++) {
            $("#dataTable").append("<tr><td>"+array[i]+"</td></tr>");
        }

        $('.summernote').summernote({
            placeholder: '实验报告内容',
            height: 500,
            lang: 'zh-CN',
            followingToolbar: false,
        });
        $(".summernote").summernote('code', $("#report").val());

        $('.summernote1').summernote({
            placeholder: '請輸入教師評語',
            height: 500,
            lang: 'zh-CN',
            followingToolbar: false,
        });
    })

    /**
     * 教师批改实验成绩
     */
    function checkHomework() {
        $.ajax({
            url: ctx + '/system/OnlineExperimentStu/checkHomeWork',
            type : 'post',
            data : JSON.stringify({experimentTeaId:$("#experimentTeaId").val(),studentId:$("#studentId").val(),teacherComment:$(".summernote1").summernote("code"),teacherScore:$("#score").val()}),
            dataType : 'json',
            contentType : 'application/json;charset=UTF-8',
            success :function (data) {
                if(data.code==500){
                    $.modal.msgError(data.msg)
                }
                if(data.code==0){
                    $.modal.msgSuccess(data.msg)
                    var int=self.setInterval(function(){  // 这个方法是说在延迟两秒后执行大括号里的方法
                        $.modal.reload();
                    },1000) //这里2000代表两秒
                }
            }
        })
    }
</script>
</html>